#include("/template/common/layout/_page_layout.html")
#@layout()

#define css()
<style>

</style>
#end

#define js()
<script type="text/javascript">
    layui.use(['table', 'layer'], function () {
        var table = layui.table
            , layer = layui.layer
            , $ = layui.jquery
            , form = layui.form;

        // 表格渲染
        var tableIns = table.render({
            elem: '#dateTable'                  //指定原始表格元素选择器（推荐id选择器）
            , id: 'dateTable'
            , even: true //开启隔行背景
            , size: 'sm' //小尺寸的表格
            , height: 'full-150'    //容器高度
            , cellMinWidth: 80       //单元格最小宽度
            , cols: [[                  //标题栏
                {type: 'numbers', fixed: true, minWidth: true}
                , {field: 'name', title: '名称',minWidth: 150,sort:true}
                , {field: 'amount', title: '预计金额(单位：元)', width: 160, sort: true, templet: '#tplMoney'}
                , {field: 'site', title: '地址', minWidth: 200,sort:true}
                , {field: 'assessmentMode', title: '评估方式', minWidth: 100,sort:true}
                , {field: 'createTime', title: '创建时间',minWidth:150, sort: true}

                , {field: 'spell',title:'回复'}, {field: 'remark', title: '备注', minWidth: 200,sort:true}
                , {title: '操作', minWidth: 240, align: 'center', toolbar: '#barOption', fixed: 'right'} //这里的toolbar值是模板元素的选择器
            ]]
            , url: '#(ctxPath)/app/projectUndertake/managementReviewTableData'
            , method: 'get'
            , request: {
                pageName: 'pageNumber' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }

            , page: true
            , limits: [30, 60, 90, 150, 300]
            , limit: 30 //默认采用30
            , loading: true
            , initSort: {
                field: 'spell'
                ,type: 'desc'
            }
            , done: function (res, curr, count) {
                $('[data-field=spell]').addClass("layui-hide");
            }
        });

        table.on('tool(dateTable)', function (obj) {
            var data = obj.data;
            if (obj.event === "see"){
                window.location.href = "#(ctxPath)/app/projectUndertake/managementReviewSee?id=" + data.id;
            } else if (obj.event === "accept"){
                layer.confirm('确定同意吗', function (index) {
                    $.post("#(ctxPath)/app/projectUndertake/managementReviewAccept",{id:data.id},function () {
                        layer.close(index);
                        layer.msg("同意成功！");
                        reloadTable();
                    });
                });
            } else if (obj.event === "refuse"){
                layer.confirm('确定拒绝吗', function (index) {
                    $.post("#(ctxPath)/app/projectUndertake/managementReviewRefuse",{id:data.id},function () {
                        layer.close(index);
                        layer.msg("拒绝成功！");
                        reloadTable();
                    });
                });
            }
        });

        var reloadTable = function () {
            table.reload('dateTable', {
                url: '#(ctxPath)/app/projectUndertake/managementReviewTableData'
            });
        };


    });

</script>
<script type="text/html" id="tplMoney">{{formatCurrency(d.amount)}}</script>
#end

#define content()
<div class="layui-fluid">
    <table id="dateTable" lay-filter="dateTable"></table>
</div>

<script type="text/html" id="barOption">

    #[[
    {{#  if(d.spell != '0'){ }}
    ]]#
    <a class="layui-btn layui-btn-xs" lay-event="see">查看</a>
    #[[
    {{#  } }}
    ]]#


    #[[
    {{#  if(d.spell == '3'){ }}
    ]]#
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="accept">通过</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="refuse">不通过</a>
    #[[
    {{#  } }}
    ]]#

</script>
#end